<?php
// +----------------------------------------------------------------------
// | ZGUAN [ 致力于帮助更多的中小企业实现低成本数字化转型 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2024 https://www.zguan.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ZGUAN 并不是自由软件，未经许可不能去掉ZGUAN 相关版权
// +----------------------------------------------------------------------
// | Author: ZGUAN Team <admin@zguan.cn>  0769-82282996  15899929162
// +----------------------------------------------------------------------
namespace app\validate\room;

use think\Validate;

class RoomBasicValidate extends Validate
{
    protected $rule = [
        'property_id|物业' => 'require|number',
        'unit_id|楼栋' => 'number',
        'room_name|房间名称' => 'require',
        'room_rent|租金金额' => 'float',
        'room_deposit|押金金额' => 'float',
        'floor_name|第 * 层' => 'integer|elt:120',
        'floor_total|共 * 层' => 'integer|elt:120',
        'room_num|房间数量' => 'integer|elt:20',
        'hall_num|客餐厅数量' => 'integer|elt:20',
        'who_num|卫生间数量' => 'integer|elt:10',
    ];

    public function sceneAdd()
    {
        return $this->remove('id', 'require');
    }

    public function sceneEdit()
    {
        return $this->remove('id', 'require')
            ->remove('property_id', 'require');
    }

    public function sceneDel()
    {
        return $this->only(['id'])->append('id', 'require|number');
    }

    public function sceneAddBatcRoom()
    {
        return $this->only(['property_id', 'room_data'])
            ->append('room_data', 'require|checkRoomBatchData');
    }

    public function checkRoomBatchData($value, $rule, $data = [])
    {
        if (!is_array($value) || !isset($value[0])) {
            return "房间数据错误";
        }
        foreach ($value as $v) {

        }
        return true;
    }
}